/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.model;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Thuan
 */
@Entity
@Table(name = "ManagerOfBatch")
@NamedQueries({
    @NamedQuery(name = "ManagerOfBatch.findAll", query = "SELECT m FROM ManagerOfBatch m"),
    @NamedQuery(name = "ManagerOfBatch.findByManagerId", query = "SELECT m FROM ManagerOfBatch m WHERE m.managerOfBatchPK.managerId = :managerId"),
    @NamedQuery(name = "ManagerOfBatch.findByBatchId", query = "SELECT m FROM ManagerOfBatch m WHERE m.managerOfBatchPK.batchId = :batchId"),
    @NamedQuery(name = "ManagerOfBatch.findBySemesterId", query = "SELECT m FROM ManagerOfBatch m WHERE m.managerOfBatchPK.semesterId = :semesterId")})
public class ManagerOfBatch implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ManagerOfBatchPK managerOfBatchPK;
    @JoinColumn(name = "semesterId", referencedColumnName = "semesterId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Semester semester;
    @JoinColumn(name = "managerId", referencedColumnName = "managerId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Manager manager;
    @JoinColumn(name = "batchId", referencedColumnName = "batchId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Batch batch;

    public ManagerOfBatch() {
    }

    public ManagerOfBatch(ManagerOfBatchPK managerOfBatchPK) {
        this.managerOfBatchPK = managerOfBatchPK;
    }

    public ManagerOfBatch(int managerId, int batchId, int semesterId) {
        this.managerOfBatchPK = new ManagerOfBatchPK(managerId, batchId, semesterId);
    }

    public ManagerOfBatchPK getManagerOfBatchPK() {
        return managerOfBatchPK;
    }

    public void setManagerOfBatchPK(ManagerOfBatchPK managerOfBatchPK) {
        this.managerOfBatchPK = managerOfBatchPK;
    }

    public Semester getSemester() {
        return semester;
    }

    public void setSemester(Semester semester) {
        this.semester = semester;
    }

    public Manager getManager() {
        return manager;
    }

    public void setManager(Manager manager) {
        this.manager = manager;
    }

    public Batch getBatch() {
        return batch;
    }

    public void setBatch(Batch batch) {
        this.batch = batch;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (managerOfBatchPK != null ? managerOfBatchPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ManagerOfBatch)) {
            return false;
        }
        ManagerOfBatch other = (ManagerOfBatch) object;
        if ((this.managerOfBatchPK == null && other.managerOfBatchPK != null) || (this.managerOfBatchPK != null && !this.managerOfBatchPK.equals(other.managerOfBatchPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.app.model.ManagerOfBatch[ managerOfBatchPK=" + managerOfBatchPK + " ]";
    }

}
